package com.dong.nio;

import org.springframework.core.io.buffer.*;

import java.nio.ByteBuffer;
import java.util.Arrays;

/**
 * description
 *
 * @author Administrator 2021/09/14 9:34
 */
public class DataBufferTest {

    public static void main(String[] args) {
        DataBufferFactory factory = new DefaultDataBufferFactory();
        DefaultDataBuffer dataBuffer = (DefaultDataBuffer) factory.allocateBuffer();
        byte[] bytes = {'a','b','c'};

        dataBuffer.write(bytes);

        System.out.println(dataBuffer.capacity());
        System.out.println(dataBuffer.readPosition());
        System.out.println(dataBuffer.writePosition());

        byte a = dataBuffer.read();
        System.out.println(a == bytes[0]);

        System.out.println(dataBuffer.readPosition());
        System.out.println(dataBuffer.writePosition());

        DataBufferUtils.release(dataBuffer);
    }
}
